package com.woniuxy02;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

/**
 * @author 作者
 * @create 2025-06-05 10:50
 */
public class Test03 {
    public static void main(String[] args) throws ParseException {
        Calendar calendar = Calendar.getInstance();
        System.out.println(calendar.get(Calendar.YEAR));
        System.out.println(calendar.get(1));
        System.out.println(calendar);
        System.out.println(calendar.get(Calendar.YEAR)+"-"+calendar.get(Calendar.MONTH)+"-"+calendar.get(Calendar.DAY_OF_MONTH));
        System.out.println(new Date(calendar.getTimeInMillis()));
        //日历类用于日期计算
        //add(int field, int amount)
        //int field对哪个部分进行运算,int amount运算数
        calendar.add(Calendar.YEAR, -1);
        System.out.println(new Date(calendar.getTimeInMillis()));
        calendar.add(Calendar.MONTH, -1);
        System.out.println(new Date(calendar.getTimeInMillis()));

    }


}
